#ifndef __POPUP_DATABASE_H__
#define __POPUP_DATABASE_H__

#include <string>
#include "PopupDatabaseUI.hpp"

struct CppSQLite3DB;

namespace Popup
{
  class PopupSqlite3Database : public DatabaseUI
  {
  public:
    PopupSqlite3Database(const std::string & p_path);
    ~PopupSqlite3Database();

    // @Override
    bool getAllUsers(UserLoginMap & p_usersMap);

    // @Override
    ConnectionEcode newUser(const std::string & p_login,
                            const std::string & p_password,
                            const std::string & p_nickname,
                            const std::string & p_avatar,
                            User **p_user,
                            std::string & p_message);

    // @Override
    virtual bool authenticate(const std::string & p_login,
                              const std::string & p_password,
                              std::string & p_message);

    // @Override
    virtual bool updateNickname(User *p_user,
                                const std::string & p_newNickname,
                                std::string & p_message);
    // @Override
    virtual bool updateAvatar(User *p_user,
                              const std::string & p_newAvatar,
                              std::string & p_message);

    // @Override
    virtual bool updateUserRates(UserID p_userID,
                                  UserRateItem p_itemKey,
                                  //ItemUpdateOperation p_itemUpdateOperation,
                                  StatisticItemUpdateResult & p_updateResult,
                                  std::string & p_message);

    // @Override
    virtual bool getUserStatitics(UserID p_userID,
                                  UserStatistics & p_stats,
                                  std::string & p_message);

    //! \return True if the user is registered in database
    bool existsUser(const std::string & p_login);

  private:
    CppSQLite3DB *db;
    bool connected;
  };
}

#endif // __POPUP_DATABASE_H__
